package ducksimulator

import "fmt"

type Duck struct {
	flyBehavior FlyBehavior
	quackBehavior QuackBehavior
}

func (d *Duck) PerformFly() {
	d.flyBehavior.Fly()
}

func (d *Duck) PerformQuack() {
	d.quackBehavior.Quack()
}

func (d *Duck) Swim() {
	fmt.Println("All ducks float, even decoys!")
}

func (d *Duck) Display() {

}

func (d *Duck) SetFlyBehavior(f FlyBehavior) {
	d.flyBehavior = f
}

// subclassing
// make it private to prevent new(ducksimulator.mallardDuck)
type mallardDuck struct {
	Duck
}
func (d *mallardDuck) Display() {
	fmt.Println("I am a real mallard duck!")
}

// constructor-like factory functions
func NewMallardDuck() *mallardDuck {
	m := mallardDuck{}
	m.flyBehavior = FlyWithWings{}
	m.quackBehavior = Quack{}
	return &m
}
